"use strict";
cc._RF.push(module, '2a5504fMB9Ox7RlwW7Bb530', 'oppoApi');
// scripts/engines/services/miniGameContent/oppo/oppoApi.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
Object.defineProperty(exports, "__esModule", { value: true });
var miniApp_1 = require("../miniApp");
var gameConfig_1 = require("../../../configs/gameConfig");
var gameEngine_1 = require("../../../gameEngine");
var oppo = window['qg'];
var OppoApi = /** @class */ (function (_super) {
    __extends(OppoApi, _super);
    function OppoApi() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.m_appId = '30490355';
        _this.m_secret = '5b004Cc3F9399878C51edf973F7af00C';
        _this.m_adUnitId = '301459';
        _this.m_PortalId = "301461";
        _this.m_nAdIdList = ["305202", "305201", "305200"];
        _this.m_BannerId = "304800";
        _this.m_BannerIdList = ["304799", "304800", "304797"];
        //protected m_adUnitIdList: string[] = ['1flm74jfpgml93lhhb', '134he4gc7igj13du0e', 'pca9a4n61d9ak41ouq'];
        // protected m_InsertId: string = "";
        //录屏管理器
        _this.m_gameRecorderManager = null;
        //录屏文件保存完地址
        _this.m_gameRecordVideoUrl = null;
        //视频广告组件
        _this.m_videoAd = null;
        //原生广告
        _this.m_nativeAd = null;
        _this.nowNAdId = 0;
        //banner广告
        _this.mowBanner = 0;
        // protected m_Bannerad: any = null
        // private bannerSuccese: boolean = true
        // //互推盒子-横幅
        // private m_bannerAd: any = null;
        //互推盒子-九宫格
        _this.m_portalAd = null;
        _this.m_Bannerad = null;
        _this.bannerSuccese = true;
        _this.m_gameRecordTimeNow = 0;
        _this.m_localInBlockCity = false;
        return _this;
    }
    OppoApi.prototype.commitRank = function (rankId, score) {
        return __awaiter(this, void 0, Promise, function () {
            return __generator(this, function (_a) {
                console.error('#48102640 未实现');
                return [2 /*return*/, Promise.resolve(false)];
            });
        });
    };
    OppoApi.prototype.showRank = function (rankId) {
        return __awaiter(this, void 0, Promise, function () {
            return __generator(this, function (_a) {
                console.error('#51102648 未实现');
                return [2 /*return*/, Promise.resolve(false)];
            });
        });
    };
    OppoApi.prototype.navigateToMiniGame = function (appId, successCallback, failCallback) {
        console.error('#54102651 未实现跳转');
    };
    OppoApi.prototype.vibrate = function (type) {
    };
    OppoApi.prototype.addShortcut = function () {
        // throw new Error("Method not implemented.");
        return null;
    };
    OppoApi.prototype.getShareVideoRank = function (sortType, successCb) {
        // throw new Error("Method not implemented.");
    };
    OppoApi.prototype.drawUrlImage = function (url, overCb) {
        // throw new Error("Method not implemented.");
    };
    OppoApi.prototype.showVideo = function (videoUrl) {
        // throw new Error("Method not implemented.");
    };
    OppoApi.prototype.subscribeMessage = function (successCallback, failCallback, completeCallback) {
        // throw new Error("Method not implemented.");
    };
    OppoApi.prototype.showAddFavoriteGuide = function (successCallback, failCallback, completeCallback) {
        // throw new Error("Method not implemented.");
    };
    OppoApi.prototype.StartRecordSound = function () {
        // throw new Error("Method not implemented.");
    };
    OppoApi.prototype.StopRecordSound = function (successCallback) {
        // throw new Error("Method not implemented.");
    };
    OppoApi.prototype.PlayLastRecordSound = function (scale, successCb, errorCb) {
        // throw new Error("Method not implemented.");
    };
    OppoApi.prototype.operateGameLive = function () {
        // throw new Error("Method not implemented.");
    };
    OppoApi.prototype.getUserInfo = function (params) {
        // oppo.getUserInfo(params);
    };
    OppoApi.prototype.showToast = function (params) {
        oppo.showToast(params);
    };
    OppoApi.prototype.showLoading = function (params) {
        oppo.showLoading(params);
    };
    OppoApi.prototype.hideLoading = function () {
        oppo.hideLoading();
    };
    OppoApi.prototype.preCreateUnits = function () {
        this.CheckLocalToBlockCityList();
        // this.createRewardedVideovalidAppIdAd({ adUnitId: this.m_adUnitId });
        // this.m_gameRecorderManager = oppo.getGameRecorderManager();
    };
    OppoApi.prototype.onShareAppMessageGetReward = function (successCallback, errorCallback, completeCallback, isNeedModal) {
        //
        // let shareAppRewardFunction = () => {
        //     oppo.shareAppMessage({
        //         templateId: "2w1ji856pahdij2f29", // 替换成通过审核的分享ID
        //         query: "",
        //         success: () => {
        //             console.log("oppo 分享成功");
        //             successCallback();
        //             completeCallback && completeCallback();
        //         },
        //         fail: (e) => {
        //             console.log("oppo 分享失败");
        //             errorCallback(e);
        //             completeCallback && completeCallback();
        //         },
        //     })
        // }
        // //
        // if (isNeedModal) {
        //     oppo.showModal({
        //         title: '游戏奖励',
        //         content: '视频拉取失败,分享游戏也可领取视频奖励',
        //         confirmText: '分享',
        //         showCancel: true,
        //         success: (info: { errMsg: string, confirm: boolean, cancel: boolean }) => {
        //             console.log('oppo 分享success');
        //             if (info.confirm) {
        //                 shareAppRewardFunction();
        //             } else {
        //                 errorCallback(null);
        //                 completeCallback();
        //             }
        //         },
        //     })
        // } else {
        //     shareAppRewardFunction();
        // }
    };
    OppoApi.prototype.createMoreGameBtn = function () {
        // const buttonWithText = oppo.createMoreGamesButton({
        //     type: "text",
        //     style: {
        //         left: 120,
        //         top: 400,
        //         width: 120,
        //         height: 100,
        //         backgroundColor: "#ffffff",
        //         borderColor: "#ffff00",
        //         borderWidth: 10,
        //         borderRadius: 10,
        //         textAlign: "left",
        //         fontSize: 13,
        //         lineHeight: 50,
        //         textColor: "#000000",
        //     },
        //     text: "text的button",
        //     actionType: "box",
        //     appLaunchOptions: [
        //         {
        //             appId: this.m_appId,
        //             query: oppo.getLaunchOptionsSync().query,
        //             extraData: {},
        //         },
        //         // {...}
        //     ],
        //     onNavigateToMiniGameBox(res) {
        //         console.log("跳转到小游戏盒子", res);
        //     },
        // });
    };
    OppoApi.prototype.showInterstitialAd = function (onAdClose, onFailed) {
        // if (oppo) {
        //     console.log("加抖音 插屏 广告");
        //     var interstitialAd = oppo.createInterstitialAd({
        //         adUnitId: this.m_InsertId,
        //     })
        //     interstitialAd.load()
        //     interstitialAd.onLoad(() => {
        //         console.warn('插屏广告 加载完成');
        //         interstitialAd.show().catch((err) => {
        //             console.warn('插屏广告 显示失败 ：' + JSON.stringify(err))
        //             interstitialAd.destroy();
        //             interstitialAd = null;
        //             if (onFailed) {
        //                 onFailed();
        //             }
        //         })
        //     })
        //     interstitialAd.onError((err) => {
        //         console.warn('插屏广告 加载失败' + JSON.stringify(err));
        //         interstitialAd.destroy();
        //         interstitialAd = null;
        //         if (onFailed) {
        //             onFailed();
        //         }
        //     })
        //     interstitialAd.onClose(() => {
        //         console.warn('插屏广告 关闭');
        //         if (interstitialAd != null) {
        //             interstitialAd.destroy();
        //             interstitialAd = null;
        //         }
        //         if (onAdClose) {
        //             onAdClose();
        //         }
        //     })
        // } else {
        //     onAdClose();
        // }
    };
    /** 加载原生广告 */
    OppoApi.prototype.showNativeAd = function (successCallback, errorCallback, completeCallback) {
        var _this = this;
        console.log("----------原生广告判断前----------");
        if (oppo) {
            console.log("----------原生广告判断后----------");
            if (this.m_nativeAd) {
                this.m_nativeAd.destroy();
                this.m_nativeAd = null;
            }
            this.m_nativeAd = oppo.createNativeAd({ posId: this.m_nAdIdList[this.nowNAdId] });
            this.m_nativeAd.load().then(function (res) {
                console.log(res.adList[0].creativeType, "creativeType======");
                console.log("原生广告加载成功..." + res);
                console.log(JSON.stringify(res), "this.m_nativeAd=======");
                console.log("------------  res.adList : " + res.adList);
                // console.log("------------  res.adList.adId : " + res.adList.adId);  //错误使用方法
                console.log("------------  res.adList[0].adId : " + res.adList[0].adId);
                console.log("------------  res.adList[0].imgUrlList[0] : " + res.adList[0].imgUrlList[0]);
                console.log("------------  this.m_nAdlist.imgUrlList[0] : " + JSON.stringify(_this.m_nAdlist.imgUrlList));
                _this.nowNAdId++;
                if (_this.nowNAdId == _this.m_nAdIdList.length) {
                    _this.nowNAdId = 0;
                }
                completeCallback && completeCallback();
            }).catch(function (res) {
                console.log("原生广告加载失败..." + JSON.stringify(res));
                errorCallback(res);
                completeCallback && completeCallback();
            });
            this.m_nativeAd.onLoad(function (res) {
                _this.m_nAdlist = res.adList[0];
                _this.m_nativeAd.reportAdShow({ adId: _this.m_nAdlist.adId }); //原生广告曝光上报
                successCallback(_this.m_nAdlist);
                console.log(JSON.stringify(_this.m_nativeAd), "this.m_nativeAd=======");
                console.log("------------  res.adList : " + res.adList);
                // console.log("------------  res.adList.adId : " + res.adList.adId);  //错误使用方法
                console.log("------------  res.adList[0].adId : " + res.adList[0].adId);
                console.log("------------  res.adList[0].imgUrlList[0] : " + res.adList[0].imgUrlList[0]);
                console.log("------------  this.m_nAdlist.imgUrlList[0] : " + JSON.stringify(_this.m_nAdlist.imgUrlList));
            });
        }
    };
    /** 原生广告点击上报 */
    OppoApi.prototype.reportAdClickNativeAd = function () {
        if (!this.m_nativeAd) {
            return;
        }
        this.m_nativeAd.reportAdClick({ adId: this.m_nAdlist.adId });
    };
    OppoApi.prototype.showBannerAD = function (node, successCallback, errorCallback, onCloseCallBack, setBannerPosition) {
        var _this = this;
        // const { screenWidth, screenHeight } = oppo.getSystemInfoSync();
        var _a = oppo.getSystemInfoSync(), screenWidth = _a.screenWidth, screenHeight = _a.screenHeight;
        var pos = setBannerPosition && setBannerPosition({ screenWidth: screenWidth, screenHeight: screenHeight }) || cc.v2(0, 0);
        var targetBannerAdWidth = 200;
        if (this.m_Bannerad && !this.bannerSuccese) {
            this.m_Bannerad.destroy();
            this.m_Bannerad = null;
        }
        if (this.m_Bannerad) {
            this.m_Bannerad.show()
                .then(function () {
                successCallback && successCallback();
                console.log("---------------------Banner广告直接显示成功");
            })
                .catch(function (err) {
                errorCallback && errorCallback(err);
                console.log("---------------------Banner广告直接显示组件出现问题", JSON.stringify(err));
            });
            return;
        }
        this.bannerSuccese = true;
        if (this.m_Bannerad == null) {
            this.m_Bannerad = oppo.createBannerAd({
                adUnitId: this.m_BannerIdList[this.mowBanner],
                adIntervals: 30,
                style: {
                    // width: targetBannerAdWidth,
                    // top: screenHeight - (targetBannerAdWidth / 16) * 9, // 根据系统约定尺寸计算出广告高度
                    left: pos.x,
                    top: pos.y,
                }
            }); //创建
        }
        this.m_Bannerad.onResize(function (size) {
            console.log(size.width, size.height, "banner长宽");
            //     this.m_Bannerad.style.top = size.height;//screenHeight - size.height;
            //     this.m_Bannerad.style.left = size.width;//(screenWidth - size.width) / 2;
            //     setBannerPosition && setBannerPosition({ x: this.m_Bannerad.style.left, y: this.m_Bannerad.style.top },
            //         { width: size.width, height: size.height });
        });
        this.m_Bannerad.onLoad(function () {
            if (node == null || !node.active || !node.isValid) {
                console.log("---------------------------------------------------------");
                return;
            }
            _this.mowBanner++;
            if (_this.mowBanner == _this.m_BannerIdList.length) {
                _this.mowBanner = 0;
            }
            _this.bannerSuccese = false;
            _this.m_Bannerad
                .show()
                .then(function () {
                console.log("---------------------Banner广告显示成功");
                _this.m_Bannerad.onHide(function () {
                    console.log('oppo-banner 广告隐藏');
                    onCloseCallBack && onCloseCallBack();
                });
            })
                .catch(function (err) {
                console.log("---------------------Banner广告组件显示出现问题", JSON.stringify(err));
            });
        });
        this.m_Bannerad.onError(function (e) {
            _this.bannerSuccese = false;
            console.log("---------------------Banner广告加载错误,错误原因：", JSON.stringify(e));
        });
    };
    OppoApi.prototype.hideBanner = function () {
        if (null != this.m_Bannerad) {
            this.m_Bannerad.hide();
            console.log('banner广告隐藏完成');
        }
    };
    /** OPPO九宫格互推盒子 */
    OppoApi.prototype.loadAndShowPortalAd = function (successCallback, errorCallback, completeCallback) {
        var _this = this;
        if (cc.sys.platform != cc.sys.OPPO_GAME)
            return;
        if (oppo.getSystemInfoSync().platformVersionCode >= 1076) {
        }
        else {
            console.log('快应用平台版本号低于1076，暂不支持互推盒子相关 API');
            return;
        }
        // if(this.m_portalAd)
        // {
        //     this.m_portalAd.destroy();
        //     this.m_portalAd=null;
        // }
        if (this.m_portalAd == null) {
            this.m_portalAd = oppo.createGamePortalAd({ adUnitId: this.m_PortalId });
        }
        else {
            this.m_portalAd.show().then(function () {
                successCallback();
                completeCallback && completeCallback();
                console.log('互推盒子九宫格广告显示成功');
            }).catch(function () {
                errorCallback('互推盒子九宫格广告显示失败');
                completeCallback && completeCallback();
                console.log('互推盒子九宫格广告显示失败');
                _this.m_portalAd.destroy();
                _this.m_portalAd = null;
            });
        }
        this.m_portalAd.load().then(function () {
            console.log('互推盒子九宫格广告加载成功');
            _this.m_portalAd.show().then(function () {
                successCallback();
                completeCallback && completeCallback();
                console.log('互推盒子九宫格广告显示成功');
            }).catch(function (err) {
                gameEngine_1.default.getModules().uiControlModule.showMessageBox("互推盒子显示失败~请稍后重试");
                errorCallback('互推盒子九宫格广告显示失败');
                completeCallback && completeCallback();
                console.log('互推盒子九宫格广告显示失败', JSON.stringify(err));
                _this.m_portalAd.destroy();
                _this.m_portalAd = null;
            });
        }).catch(function (err) {
            switch (err.errCode) {
                case 1001:
                    gameEngine_1.default.getModules().uiControlModule.showMessageBox("拉取次数过多暂时无法显示");
                    break;
                default:
                    gameEngine_1.default.getModules().uiControlModule.showMessageBox("更多好玩加载失败~请稍后重试~");
                    break;
            }
            completeCallback && completeCallback();
            console.log('互推盒子九宫格广告加载失败,error', JSON.stringify(err));
            _this.m_portalAd.destroy();
            _this.m_portalAd = null;
        });
        // this.m_nativeAd.onError(function(err) {
        //     console.log(JSON.stringify(err),"互推盒子加载失败")
        //   })
        // this.m_portalAd.onClose(function()
        // {
        //     this.m_portalAd.offClose();
        //     this.m_portalAd.destroy();
        //     this.m_portalAd=null;
        // });
    };
    OppoApi.prototype.loadAndShowVideoAd = function (successCallback, errorCallback, completeCallback, reportAnalyticsExplain, videoIdPos) {
        var _this = this;
        if (videoIdPos === void 0) { videoIdPos = 0; }
        console.log('ad show');
        if (this.m_videoAd == null) {
            this.m_videoAd = oppo.createRewardedVideoAd({ adUnitId: this.m_adUnitId });
        }
        // O1HD.getManagers().soundMgr.setSoundEnabled(false);
        // if (this.m_videoAd == null) {
        //     console.error('头条广告视频组件不存在');
        //     O1HD.getManagers().soundMgr.setSoundEnabled(true);
        //     errorCallback(null);
        //     return;
        // }
        var onError = function (err) {
            console.log('\
        视频Error');
        };
        this.m_videoAd.offError(onError);
        this.m_videoAd.onError(onError);
        //
        var onClose = function (res) {
            console.log('2\
                视频退出');
            if (res && res.isEnded) {
                // 给予奖励
                successCallback();
                // O1HD.getManagers().soundMgr.setSoundEnabled(true);
            }
            else {
                //
                gameEngine_1.default.getModules().uiControlModule.showMessageBox("完整观看视频才能获得奖励哦~");
                errorCallback('视频中途退出');
                // O1HD.getManagers().soundMgr.setSoundEnabled(true);
            }
            _this.m_videoAd.offClose(onClose);
            completeCallback && completeCallback();
            gameEngine_1.default.getManagers().soundMgr.setSoundEnabled(true);
        };
        //
        this.m_videoAd.load().then(function () {
            _this.m_videoAd.onClose(onClose);
            _this.m_videoAd.show().then(function () {
            }).catch(function () {
                console.log('1\
            视频显示错误');
                if (_this.m_videoAd) {
                    _this.m_videoAd.destroy();
                    _this.m_videoAd = null;
                }
                gameEngine_1.default.getModules().uiControlModule.showMessageBox("视频显示错误~请稍后重试");
                errorCallback('视频显示错误');
                _this.m_videoAd.offClose(onClose);
                completeCallback && completeCallback();
                gameEngine_1.default.getManagers().soundMgr.setSoundEnabled(true);
            });
        }).catch(function () {
            console.log('3\
        视频加载错误');
            gameEngine_1.default.getModules().uiControlModule.showMessageBox("视频加载失败~请稍后重试");
            errorCallback('视频加载错误');
            _this.m_videoAd.offClose(onClose);
            completeCallback && completeCallback();
            gameEngine_1.default.getManagers().soundMgr.setSoundEnabled(true);
            if (_this.m_videoAd) {
                _this.m_videoAd.destroy();
                _this.m_videoAd = null;
            }
        });
        this.m_videoAd.onError(function (err) {
            if (_this.m_videoAd) {
                _this.m_videoAd.destroy();
                _this.m_videoAd = null;
            }
            console.log(JSON.stringify(err), "视频加载错误原因");
        });
        //
        // const adUnitId = this.m_adUnitId;
        // console.log('oppo 视频广告', adUnitId);
        // //
        // const videoAd = oppo.createRewardedVideoAd({
        //     adUnitId: adUnitId,
        // });
        // let onError = (e: any) => {
        //     console.error('oppo 视频广告错误', e);
        //     videoAd.offError(onError);
        //     switch (Number(e.errCode)) {
        //         //没有合适的广告 可能该用户无合适的广告
        //         case 1004: {
        //             this.onShareAppMessageGetReward(successCallback, errorCallback, completeCallback, true);
        //             break;
        //         }
        //         //广告发送的次数已达当日上限
        //         // case 120002: {
        //         //     if (videoIdPos + 1 >= this.m_adUnitIdList.length) {
        //         //         this.onShareAppMessageGetReward(successCallback, errorCallback, completeCallback, true);
        //         //     } else {
        //         //         this.loadAndShowVideoAd(successCallback, errorCallback, completeCallback, videoIdPos + 1);
        //         //         return;
        //         //     }
        //         //     break;
        //         // }
        //         default: {
        //             this.showToast({ title: 'err' + e.errCode });
        //             break;
        //         }
        //     }
        // };
        // videoAd.offError(onError);
        // videoAd.onError(onError);
        // //
        // this.showLoading({ title: '请求中' });
        // let onClose = (res) => {
        //     console.log('oppo 视频广告关闭', res);
        //     if (res && res.isEnded) {
        //         // 给予奖励
        //         successCallback();
        //     } else {
        //         //
        //         errorCallback('视频中途退出');
        //     }
        //     completeCallback && completeCallback();
        //     //
        //     videoAd.offClose(onClose);
        // };
        // videoAd.load().then(() => {
        //     videoAd.show().then(() => {
        //         videoAd.onClose(onClose);
        //         this.hideLoading();
        //     }).catch(() => {
        //         errorCallback('视频显示错误');
        //         this.hideLoading();
        //         //
        //         completeCallback && completeCallback();
        //     })
        // }).catch(() => {
        //     errorCallback('视频加载错误');
        //     this.hideLoading();
        //     //
        //     completeCallback && completeCallback();
        // });
        //new
        // console.log("oppo 广告");
        // if (!this.m_videoAd) {
        //     console.warn("oppo 广告创建");
        //     this.m_videoAd = oppo.createRewardedVideoAd({
        //         adUnitId: this.m_adUnitId,
        //     });
        // }
        // const videoAd = oppo.createRewardedVideoAd({
        //     adUnitId: this.m_adUnitId,
        // });
        //
        // let onError = (e: any) => {
        //     switch (Number(e.errCode)) {
        //         case 1004: {
        //             this.onShareAppMessageGetReward(successCallback, errorCallback, completeCallback, true);
        //             break;
        //         }
        //         default: {
        //             this.showToast({title: 'err' + e.errCode});
        //             break;
        //         }
        //     }
        // };
        // videoAd.offError(onError);
        // videoAd.onError(onError);
        //
        // let onshow = () => {
        //     this.hideLoading();
        //     console.log("oppo 广告显示成功");
        //     //
        //     let listener = (res) => {
        //         console.log("oppo 关闭广告", res.isEnded);
        //         if (res.isEnded) {
        //             successCallback();
        //         } else {
        //             console.log("oppo 广告未播放完");
        //             errorCallback('广告未播放完');
        //         }
        //         completeCallback && completeCallback();
        //         //不需要的时候
        //         videoAd.offClose(listener);
        //     }
        //
        //     videoAd.onClose(listener); //这里监听广告的close 事件
        // };
        //
        // let onLoad = () => {
        //     console.log("oppo 广告加载完成");
        //     videoAd
        //         .show()
        //         .then(onshow)
        //         .catch();
        //     // console.log('55');
        // }
        //
        // let tryAgain = (err) => {
        //     console.log("广告组件出现问题 重试一次", err);
        //     // 可以手动加载一次
        //     videoAd.load().then(() => {
        //         console.log("手动加载成功");
        //         // 加载成功后需要再显示广告
        //         videoAd.show().then(onshow).catch((err) => {
        //             this.hideLoading();
        //             console.log("oppo 广告加载???", err);
        //             errorCallback('广告加载异常');
        //             completeCallback && completeCallback();
        //         });
        //     });
        // }
        //
        // this.showLoading({title: '请求中'});
        // videoAd.load().then(onLoad).catch((err) => {
        //     tryAgain(err);
        // });
    };
    OppoApi.prototype.login = function (params) {
        oppo.login(params);
    };
    OppoApi.prototype.authorize = function (params) {
        params.success && params.success();
    };
    OppoApi.prototype.gameRecordStart = function (params, onStart) {
        // if (!this.isHaveShareVideo()) return;
        // this.m_gameRecordTimeNow = Date.now();
        // this.m_gameRecordVideoUrl = null;
        // this.m_gameRecorderManager.onStart((res) => {
        //     console.log('oppo 录屏开始', res);
        //     onStart && onStart(res);
        // });
        // this.m_gameRecorderManager.onStop((res: any) => {
        //     console.log('oppo 录屏结束', res.videoPath);
        //     this.m_gameRecordVideoUrl = res.videoPath;
        // });
        // this.m_gameRecorderManager.start(params);
    };
    OppoApi.prototype.gameRecordStop = function () {
        return true;
        // if (!this.isHaveShareVideo()) return;
        // if (Date.now() - this.m_gameRecordTimeNow < 3500) {
        //     return;
        // }
        // this.m_gameRecorderManager.stop();
    };
    OppoApi.prototype.isGameRecordOver = function () {
        return this.m_gameRecordVideoUrl != null;
    };
    OppoApi.prototype.shareGameRecordVideo = function (successCb, failCb) {
        // if (!this.isHaveShareVideo()) return;
        // if (this.m_gameRecordVideoUrl) {
        //     oppo.shareAppMessage({
        //         channel: "video",
        //         title: gameConfig.GAME_NAME,
        //         desc: gameConfig.GAME_VIDEO_SHARE_DESC,
        //         extra: {
        //             hashtag_list: [gameConfig.GAME_NAME],
        //             videoPath: this.m_gameRecordVideoUrl, // 可替换成录屏得到的视频地址
        //             videoTopics: [gameConfig.GAME_NAME],
        //             video_title: gameConfig.GAME_VIDEO_SHARE_TITLE
        //         },
        //         success() {
        //             console.log("oppo 分享视频成功");
        //             successCb && successCb();
        //         },
        //         fail(e) {
        //             console.log("oppo 分享视频失败", e);
        //             failCb && failCb(e)
        //         }
        //     });
        // } else {
        //     failCb && failCb(null);
        //     console.log("oppo 分享视频为空");
        // }
    };
    /**production    线上版
     development    测试版
     preview    预览版
     * */
    OppoApi.prototype.isProduction = function () {
        return OppoApi.isProduction();
    };
    OppoApi.prototype.isHaveShareVideo = function () {
        return true;
    };
    //判断是否合法APP-ID
    OppoApi.prototype.validAppId = function () {
        // oppo.onShow((res: { query, refererInfo: { appId: string, extraData: {} } }) => {
        //     console.log(res.refererInfo.appId,this.m_appId,"appid对比")
        //     if (res.refererInfo.appId != this.m_appId) {
        //         cc.game.end();
        //         throw '非法盗用此程序将受到法律制裁';
        //     } else {
        //         console.log('oppo APP-ID 授权成功');
        //     }
        // });
    };
    OppoApi.prototype.reportAnalytics = function (EventKey, data) {
        console.log("oppo 发送埋点", EventKey, JSON.stringify(data));
        // oppo.reportAnalytics(EventKey, data);
        // console.log('oppo 发送埋点', analytics.getKey(), analytics.getObj());
        // oppo.reportAnalytics(analytics.getKey(), analytics.getObj());
        // oppo.reportAnalytics('lookVideo', {
        //     src: 'set_value',
        // });
    };
    OppoApi.prototype.clearMemory = function () {
    };
    OppoApi.prototype.shareAppMessage = function (args) {
    };
    OppoApi.prototype.createRewardedVideoAd = function (param) {
        // this.m_videoAd = oppo.createRewardedVideoAd(param);
    };
    /**production    线上版
     development    测试版
     preview    预览版
     * */
    OppoApi.isProduction = function () {
        return true;
    };
    OppoApi.prototype.CheckLocalToBlockCityList = function () {
        var _this = this;
        gameEngine_1.default.getModules().gameHttpModule.getLocalPropertyInfo(function (res) {
            _this.m_localInBlockCity = gameConfig_1.default.IP_BLOCK_CITY.includes(res.city);
        }, function (err) {
            console.debug("-------获取区域信息错误", err);
        });
    };
    OppoApi.prototype.LocalInBlockCityList = function () {
        return this.m_localInBlockCity;
    };
    OppoApi.prototype.showModal = function (params) {
    };
    return OppoApi;
}(miniApp_1.default));
exports.default = OppoApi;

cc._RF.pop();